package yf.mall.ScheduleTask;

import com.yf.response.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import yf.mall.service.MallActService;
import yf.mall.service.MallOrderService;

@Configuration      //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling   // 2.开启定时任务
public class StaticScheduleTask {
    @Autowired
    private MallActService mallActService;
    @Autowired
    private MallOrderService mallOrderService;
    /**
     * 每天凌晨俩点 活动时间一到 自动解绑活动
     * @return
     */
    @Scheduled(cron = "0 0 2 * * ?")
    public void autoUntieAct() {
        mallActService.autoUntieAct();
    }
    /**
     * 每天凌晨俩点 未支付的订单超过24小时 自动取消
     * @return
     */
   /*@Scheduled(cron = "0 0 2 * * ?")
    //@Scheduled(cron = "0/5 * * * * ? ")
    public void autoCancelOrder() {
        mallOrderService.autoCancelOrder();
    }*/
}
